console.log('\x1b[31m填充数组\x1b[0m');
const 员工 = [];
员工[0] = 'CaseyJones';
员工[1] = 'Phil Lesh';
员工[2] = 'August West';
console.log(员工);

console.log('\x1b[31m数组长度\x1b[0m');
let 宠物列表 = [];
宠物列表[30] = ['Dusty'];
console.log(宠物列表);
console.log(宠物列表.length);

console.log('------------------')

宠物列表 = ["Dusty", "Misty", "Twiggy"];
console.log(宠物列表.length);
宠物列表.length = 2;
console.log(宠物列表);
宠物列表.length = 0;
console.log(宠物列表);
宠物列表.length = 3;
console.log(宠物列表);


console.log('\x1b[31m遍历数组\x1b[0m');
const 颜色列表 = ['红', '绿', '蓝'];
for(let i = 0; i < 颜色列表.length; i++) {
    console.log(颜色列表[i]);
}

console.log('----------------');

颜色列表.forEach(
    (颜色) => console.log(颜色)
);

console.log('----------------');
const 稀疏列表 = ['壹', '贰', , '肆'];
稀疏列表.forEach(
    (元素) => {
        console.log(元素);
    }
);
if(稀疏列表[2] === undefined) {
    console.log('稀疏列表[2] 是 undefiend');
}
const 非稀疏列表 = ['壹', '贰', undefined, '肆'];
非稀疏列表.forEach(
    (元素) => {
        console.log(元素);
    }
);
